﻿namespace CyberConnect.Insteon.Messaging
{
    [System.ComponentModel.ImmutableObject(true)]
    public class DeviceMessageIncoming : DeviceMessageDecorator
    {
        private readonly DeviceAddress _DirectToAddress;

        public DeviceMessageIncoming(DeviceMessage message, DeviceAddress directToAddress)
            : base(message)
        {
            this._DirectToAddress = directToAddress;
        }

        public DeviceAddress DirectToAddress { get { return this._DirectToAddress; } }

        internal static DeviceMessageIncoming FromBytes(byte[] messageBytes)
        {
            return new DeviceMessageIncoming(new DeviceMessage(new DeviceAddress(messageBytes, 0), new MessageConfiguration(messageBytes[6]), new MessageCommand(messageBytes[7], messageBytes[8])), new DeviceAddress(messageBytes, 3));
        }
    }
}